#方法一
class Solution:
    def maximum69Number (self, num: int) -> int:
        s = str(num)
        ret = []
        flag = False
        for x in s:
            if x == "6" and flag == False:
                ret.append("9")
                flag = True
                continue
            ret.append(x)
        return int(''.join(ret))

# 方法二
class Solution:
    def maximum69Number (self, num: int) -> int:
        s = list(str(num))
        for i in range(len(s)):
            if s[i] == "6":
                s[i] = "9"
                break
        return int(''.join(s))

# 方法三
class Solution:
    def maximum69Number (self, num: int) -> int:
        digit_base = 10 ** int(math.log10(num)) if num != 0 else 0
        while digit_base > 0:
            if (num // digit_base) % 10 == 6:
                num += 3 * digit_base
                return num
            digit_base = digit_base // 10
        
        return num

            